fix(enrichment): join adjacent added lines before secret-scan matching#2468
Conversation
Secret-scan matched each added diff line independently, so a real credential split across two added lines via string concatenation (e.g. `const a = "AKIA..."; const b = a + "REST";`) never appeared as a single matchable token on either line and evaded every RULES regex. Extract quoted string-literal contents per added line and, when the line doesn't already match on its own, join the immediately-preceding line's last literal with the current line's first literal and test that too (downgraded to medium confidence — a joined pair is a heuristic, not a direct match). Bounded to consecutive added lines only: a hunk boundary, context line, or removed line resets the window, so this only ever catches the realistic "two sequential variable assignments" shape, not an unbounded cross-file join. Existing per-line detection is untouched and unweakened. Added review-enrichment/test/secret-scan.test.ts (previously untested) covering both the pre-existing single-line rules and the new cross-line join, including negative cases for context-line/hunk- boundary breaks and duplicate-finding avoidance. Fixes #2454
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 05:12:38 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
Secret key flag is a false positive, merging. |
Summary
scanPatch(the secret-scan analyzer's only live entry point, viascanSecrets/secret/descriptor.ts) matched each added diff line independently, so a real credential split across two added lines via string concatenation (const a = "AKIA..."; const b = a + "REST";) never appeared as a single matchable token on either line and evaded everyRULESregex.mediumconfidence since a joined pair is a heuristic, not a direct contiguous match.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typecheck(root — unaffected, nosrc/**changed)npm run test:coverage— N/A for this PR's own diff:review-enrichment/**is a separate workspace excluded from the Codecovsrc/**patch gate (ownnpm run rees:testrunner instead, see below)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderate— 0 vulnerabilitiesAlso ran
npm run rees:test(the analyzer package's own gate, part oftest:ci): 374/374 passing, including a newreview-enrichment/test/secret-scan.test.ts(9 tests) covering the pre-existing single-line rules plus 5 new tests for the cross-line join: the concatenation-split regression case itself, a context-line break, a hunk-boundary break, no-double-report when a line already matched directly, and a false-positive guard for two unrelated short literals.npm run db:migrations:checkalso unaffected/green.Safety
Notes
scanAddedLinesForSecrets(a second, unused export in the same file with the same per-line-only gap) was left untouched — it has zero callers anywhere in the codebase, so fixing it would add untestable dead-code coverage; out of scope for this fix.